package com.lagou.bak;

import org.apache.flink.streaming.api.datastream.ConnectedStreams;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.co.CoMapFunction;

public class ConnectDemod {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        DataStreamSource<String> data1 = env.addSource(new ParallelSourceRich());
        DataStreamSource<String> data2 = env.addSource(new ParalleSource());
        ConnectedStreams<String, String> connect = data1.connect(data2);
        SingleOutputStreamOperator<String> maped = connect.map(new CoMapFunction<String, String, String>() {
            @Override
            public String map1(String value) throws Exception {
                return value + "aaaa";
            }

            @Override
            public String map2(String value) throws Exception {
                return value;
            }
        });
        maped.print().setParallelism(1);
        env.execute();
    }
}
